using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MicroMsg.UI.UserContrl
{
	public class InputPhoneNumCtrl : UserControl
	{
		public delegate void UIEvent(object sender, object object_0);
		public delegate bool DlgCheckPhoneNumber(string strNum);
		public bool mBIsInputDone;
		internal Grid LayoutRoot;
		internal Button btnCountry;
		internal TextBlock txtCountry;
		internal PhoneTextBox txtInNumber;
		private bool _contentLoaded;
		public event InputPhoneNumCtrl.UIEvent mEventDone;
		public event InputPhoneNumCtrl.UIEvent mEventNotDone;
		public InputPhoneNumCtrl()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.InputPhoneNumCtrl_Loaded));
			this.ResetInput();
		}
		private void InputPhoneNumCtrl_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void btnCountry_Click(object sender, RoutedEventArgs e)
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/CommonUseControl/SelectPhoneContryPage.xaml", new object[]
			{
				this.txtCountry.get_Text(),
				new DlgSelectCountry(this.dlgSetCountry)
			}, false);
		}
		private void dlgSetCountry(string strNewCountry)
		{
			if (strNewCountry != null)
			{
				this.txtCountry.set_Text(strNewCountry);
			}
		}
		private void txtInNumber_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void txtInNumber_TextChanged(object sender, TextChangedEventArgs e)
		{
			this.checkIsInputDone();
		}
		private void txtInNumber_KeyDown(object sender, KeyEventArgs e)
		{
		}
		private bool checkIsInputDone()
		{
			bool flag = false;
			if (ToolFunction.checkIsPhoneNumber(this.txtInNumber.get_Text()))
			{
				flag = true;
			}
			if (flag)
			{
				this.mBIsInputDone = true;
				if (this.mEventDone != null)
				{
					this.mEventDone(null, null);
				}
			}
			else
			{
				this.mBIsInputDone = false;
				if (this.mEventNotDone != null)
				{
					this.mEventNotDone(null, null);
				}
			}
			return flag;
		}
		public string GetPhoneNumber()
		{
			string numbersFromString = ToolFunction.GetNumbersFromString(this.txtInNumber.get_Text());
			if (SelectPhoneContryPage.sStrSelectedCountry == null)
			{
				return numbersFromString;
			}
			List<string> list = Enumerable.ToList<string>(SelectPhoneContryPage.sStrSelectedCountry.Split(new string[]
			{
				" "
			}, 1));
			if (list != null && list.get_Count() != 0)
			{
				return list.get_Item(0) + numbersFromString;
			}
			return numbersFromString;
		}
		public void ResetInput()
		{
			SelectPhoneContryPage.ResetCountryList();
			SelectPhoneContryPage.GetDataSource();
			this.txtInNumber.set_Text("");
			AreaCode defaultAreaCode = SelectPhoneContryPage.GetDefaultAreaCode();
			if (defaultAreaCode != null)
			{
				SelectPhoneContryPage.sStrSelectedCountry = defaultAreaCode.ToString();
			}
			this.txtCountry.set_Text(SelectPhoneContryPage.sStrSelectedCountry);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/CommonUseControl/InputPhoneNumCtrl.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.btnCountry = (Button)base.FindName("btnCountry");
			this.txtCountry = (TextBlock)base.FindName("txtCountry");
			this.txtInNumber = (PhoneTextBox)base.FindName("txtInNumber");
		}
	}
}
